class PostAccess
  attr_accessor :id, :name
  
  ALLOW_ALL = 1
  FRIENDS_ONLY = 2
  DENY_ALL = 3

  def initialize(options = {})
    options = options.symbolize_keys
    @id, @name = options[:id], options[:name]
  end
  
  def symbol
    @id.to_s.downcase.intern
  end

  def self.[](value)
    @@data.find { |data| data.symbol == value.to_s.downcase.intern }
  end

  def self.find(id)
    @@data.find { |data| data.id.to_s == id.to_s }
  end

  def self.find_all
    @@data.dup
  end
  
  @@data = [
    PostAccess.new(:id=>1, :name=>"Доступ всех"),
    PostAccess.new(:id=>2, :name=>"Только друзья"),
    PostAccess.new(:id=>3, :name=>"Запретить всем")
  ]
end
